﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ContextMenu.aspx.cs" Inherits="HandLab.WebApp.RadControls.ContextMenu" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        // create a new node and add it to the node collection
        function AddNodeToList(list, text) {
            var node = new Telerik.Web.UI.RadTreeNode();
            node.set_text(text);
            list.add(node);
        }
        function HandleInternalNodeContextMenu(sender, args) {
            var node = args.get_node();
            // handle the "Reset nodes" menu item
            if (args.get_menuItem().get_text() == "Reset nodes") {
                // track changes so they will persist
                sender.trackChanges();
                var nodeList = node.get_nodes();
                // clear the node's children
                nodeList.clear();
                // add a new set to the node collection
                AddNodeToList(nodeList, "English");
                AddNodeToList(nodeList, "French");
                AddNodeToList(nodeList, "German");
                AddNodeToList(nodeList, "Spanish");
                // commit the changes
                sender.commitChanges();
                // cancel the event to prevent the postback
                args.set_cancel(true);
            }
        }
    </script>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Sunset" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick"
            OnClientContextMenuItemClicking="HandleInternalNodeContextMenu">
            <ContextMenus>
                <telerik:RadTreeViewContextMenu ID="LeafMenu" runat="server" Skin="Sunset">
                    <Items>
                        <telerik:RadMenuItem runat="server" Text="Move up" />
                        <telerik:RadMenuItem runat="server" Text="Move down" />
                        <telerik:RadMenuItem runat="server" Text="Delete" />
                    </Items>
                </telerik:RadTreeViewContextMenu>
                <telerik:RadTreeViewContextMenu ID="InternalNodeMenu" runat="server" Skin="Sunset">
                    <Items>
                        <telerik:RadMenuItem runat="server" Text="Reset nodes" />
                    </Items>
                </telerik:RadTreeViewContextMenu>
            </ContextMenus>
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="Languages" Expanded="true" ContextMenuID="InternalNodeMenu">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="English" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="French" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="German" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="Spanish" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Subtitles" Expanded="true" ContextMenuID="InternalNodeMenu">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="English" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="French" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="German" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                        <telerik:RadTreeNode runat="server" Text="Spanish" ContextMenuID="LeafMenu">
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>
    </telerik:RadAjaxPanel>
</asp:Content>
